<%@ include file="header.jsp" %>

<c:if test="${empty sessionScope.user_id}">
	<jsp:forward page="/form/login.jsp" />
</c:if>

<h1>Mes Ventes</h1>
<hr style="clear : both" />
<c:forEach var="vente" items="${requestScope.ventes}" >
	<div class="infosVendeur">
		<c:choose>
			<c:when test="${empty requestScope.action}">
				Note : ${vente.note}<br />
				${vente.commentaire}
			</c:when>
			<c:otherwise>
				<a href="acheter?action=voir_transaction&vente=${vente.idVente}">Voir la transaction</a>
			</c:otherwise>
		</c:choose>
	</div>
	
	<div class="message">
		<div class="cadreAvatar">
			<img src="/MiniIBay/images/${vente.photo}" class="avatar_message" alt="Photo du produit" />
		</div>
		<div style="float : left;">
			<b>Achet&eacute; par : <a href="/MiniIBay/vendeur?identifiant=${vente.idAcheteur}">${vente.pseudo}</a></b><br />
			<p class="infosSmall">effectu&eacute; le : ${vente.date}</p>
			${vente.produit}<br/>
			Nombre : ${vente.nombre} <br/>
			Prix : ${vente.prix} &euro;<br/>
			Etat : ${vente.etat}
		</div>
		<hr style="clear : both" />
	</div>
</c:forEach>

<div class="barreGrise">
	<div class="gauche">Page &nbsp;&nbsp;
		<c:if test="${requestScope.page > 1}">
			<a href="mesventes?page=1&action=${requestScope.action}" style="text-decoration : none" title="premi&egrave;re page"><<</a>
		</c:if>
		&nbsp;&nbsp;
		<c:if test="${requestScope.page > 1}">
			<a href="mesventes?page=${requestScope.page - 1}&action=${requestScope.action}" style="text-decoration : none" title="page pr&eacute;c&eacute;dente"><</a>
		</c:if>
		&nbsp;
		
		<c:forEach var="num" begin="${requestScope.page-5 < 1 ? 1 : requestScope.nb_results - 5}" end="${requestScope.page-1}" >
			<a href="mesventes?page=${num}&action=${requestScope.action}">${num}</a>
		</c:forEach>
		
		<c:choose>
			<c:when test="${empty requestScope.page}">
				<b>1</b>
			</c:when>
			<c:otherwise>
				<b>${requestScope.page}</b>
			</c:otherwise>
		</c:choose>
		
		<c:forEach var="num" begin="${requestScope.page + 1}" end="${requestScope.page + 5 > requestScope.nb_results ? requestScope.nb_results : requestScope.page + 5}" >
			<a href="mesventes?page=${num}&action=${requestScope.action}">${num}</a>
		</c:forEach>
		
		&nbsp;
		<c:if test="${requestScope.page < requestScope.nb_results}">
			<a href="mesventes?page=${requestScope.page + 1}&action=${requestScope.action}" style="text-decoration : none" title="page suivante">></a>
		</c:if>
		&nbsp;&nbsp;
		<c:if test="${requestScope.page < requestScope.nb_results}">
			<a href="mesventes?page=${requestScope.nb_results}&action=${requestScope.action}" style="text-decoration : none" title="derni&egrave;re page">>></a>
		</c:if>
	</div>
</div>
<br style="clear : both;" />

<%@ include file="footer.jsp" %>